<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f0f0f0;
        }

        .container {
            perspective: 1000px;
        }

        .rotate-image {
            width: 200px;
            /* 根据需要设置图片宽度 */
            transition: transform 0.6s ease;
            /* 默认的旋转过渡效果 */
        }

        @keyframes rotate {
            from {
                transform: rotate(0deg);
            }

            to {
                transform: rotate(360deg);
            }
        }

        @keyframes reverse-rotate {
            from {
                transform: rotate(360deg);
            }

            to {
                transform: rotate(0deg);
            }
        }

        .rotate-image:hover {
            animation: rotate 2s linear infinite;
            /* 鼠标悬停时不停旋转 */
        }

        .rotate-image:not(:hover) {
            animation: reverse-rotate 0.6s ease forwards;
            /* 鼠标离开时反向旋转 */
        }
    </style>
</head>

<body>
    <div class="container">
        <img src="your-image-url.jpg" alt="旋转图片" class="rotate-image">
    </div>
</body>

</html>